Proposer un code permettant de regrouper les données contenues dans anime.zip dans un seul et même data.frame.
Pour pouvoir charger des fichiers csv et les fusionner en un seul tableau, il faut que : 1. ils soient tous au même endroit (dans un même dossier); 2. les variables (ou colonnes) soit identiques (nom et type).
Dans notre situation, les fichiers sont dans le même dossier “anime” et possèdent les mêmes colonnes, mais lorsque nous essayons de charger tous les fichiers en même temps, une erreur sort. Effectivement, un des fichiers ne possède pas le même type que les autres pour la colonne ‘episode’. Le fichier “anime_Unkwown” a une variable ‘episode’ de type character et non pas double comme les autres fichiers.
anime_num <- list.files(path = "anime", full.names = TRUE) %>%
lapply(read_csv) %>%
bind_rows
Nous avons chargé et fusionné tous les fichiers “anime_x” (‘episode’ de type double) ensemble (rappel : ils sont dans le même dossier).
anime_unknown <- read_csv("anime_Unknown.csv",
col_types = cols(episodes = col_double()))
Puis nous chargeons le dernier fichier, “anime_Unkwown” (qu’on a sorti du dossier), en précisant que nous voulons que la variable ‘episode’ soit de type double (traduit alors par des NA.).
animes <- rbind(anime_num, anime_unknown)
animes
## # A tibble: 12,294 × 10
## anime_id name genre type episodes rating members rating_10 rating_100
## <dbl> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 32281 Kimi no… Drama, … Movie 1 9.37 200630 9.37 128.
## 2 15335 Gintama… Action,… Movie 1 9.1 72534 9.1 122.
## 3 28851 Koe no … Drama, … Movie 1 9.05 102733 9.05 121.
## 4 199 Sen to … Adventu… Movie 1 8.93 466254 8.93 121.
## 5 12355 Ookami … Fantasy… Movie 1 8.84 226193 8.84 130.
## 6 164 Mononok… Action,… Movie 1 8.81 339556 8.81 126.
## 7 7311 Suzumiy… Comedy,… Movie 1 8.81 240297 8.81 126.
## 8 28957 Mushish… Adventu… Movie 1 8.75 32266 8.75 120.
## 9 431 Howl no… Adventu… Movie 1 8.74 333186 8.74 116.
## 10 31757 Kizumon… Action,… Movie 1 8.73 34347 8.73 120.
## # … with 12,284 more rows, and 1 more variable: rating_1000 <dbl>
Enfin, nous regroupeons les deux dataframes précédents dans un unique dataframe que l’on nomme “animes”. Nous avons donc un dataframe composé de 12294 observations, pour 10 variables.
Observer pour chaque variable, le nombre et la proportion de valeurs manquantes.
# Pour toute la table
# nombre
table(is.na(animes))
##
## FALSE TRUE
## 121593 1347
# proportion
sum(is.na(animes))/prod(dim(animes))
## [1] 0.01095656
# Pour chaque variable
# nombre
summary(animes)
## anime_id name genre type
## Min. : 1 Length:12294 Length:12294 Length:12294
## 1st Qu.: 3484 Class :character Class :character Class :character
## Median :10260 Mode :character Mode :character Mode :character
## Mean :14058
## 3rd Qu.:24794
## Max. :34527
##
## episodes rating members rating_10
## Min. : 1.00 Min. : 1.670 Min. : 5 Min. : 1.670
## 1st Qu.: 1.00 1st Qu.: 5.880 1st Qu.: 225 1st Qu.: 5.880
## Median : 2.00 Median : 6.570 Median : 1550 Median : 6.570
## Mean : 12.38 Mean : 6.474 Mean : 18071 Mean : 6.474
## 3rd Qu.: 12.00 3rd Qu.: 7.180 3rd Qu.: 9437 3rd Qu.: 7.180
## Max. :1818.00 Max. :10.000 Max. :1013917 Max. :10.000
## NA's :340 NA's :230 NA's :230
## rating_100 rating_1000
## Min. : 22.26 Min. : 167.0
## 1st Qu.: 82.09 1st Qu.: 588.0
## Median : 91.85 Median : 657.0
## Mean : 90.62 Mean : 647.4
## 3rd Qu.:100.66 3rd Qu.: 718.0
## Max. :142.29 Max. :1000.0
## NA's :230 NA's :230
sapply(animes, function(x) sum(is.na(x)))
## anime_id name genre type episodes rating
## 0 0 62 25 340 230
## members rating_10 rating_100 rating_1000
## 0 230 230 230
# proportion
colMeans(is.na(animes))
## anime_id name genre type episodes rating
## 0.000000000 0.000000000 0.005043110 0.002033512 0.027655767 0.018708313
## members rating_10 rating_100 rating_1000
## 0.000000000 0.018708313 0.018708313 0.018708313
Dans la colonne type, nous avons 25 valeurs ‘NA’. Nous décidons de changer ces valeurs ‘NA’ en un autre type nommé “Other” et qui nous sera utile par la suite.
animes <- animes %>% replace_na(list(type = 'Other'))
Représenter graphiquement la distribution du nombre d’épisodes.
Tout d’abord, nous regroupons les lignes concernées : les animes de type TV.
anime_tv <- animes[animes$type %in% "TV", ]
anime_tv
## # A tibble: 3,787 × 10
## anime_id name genre type episodes rating members rating_10 rating_100
## <dbl> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 32935 Haikyuu… Comedy,… TV 10 9.15 93351 9.15 127.
## 2 24701 Mushish… Adventu… TV 10 8.88 75894 8.88 120.
## 3 21939 Mushish… Adventu… TV 10 8.8 101351 8.8 124.
## 4 22145 Kuroshi… Comedy,… TV 10 8.37 122895 8.37 116.
## 5 29095 Grisaia… Drama, … TV 10 8.08 111962 8.08 108.
## 6 30831 Kono Su… Adventu… TV 10 8.03 244877 8.03 111.
## 7 397 Seikai … Action,… TV 10 7.97 13888 7.97 105.
## 8 19703 Kyousou… Action,… TV 10 7.95 67732 7.95 110.
## 9 15315 Mondaij… Comedy,… TV 10 7.85 218231 7.85 111.
## 10 24135 Nobunag… Histori… TV 10 7.79 25167 7.79 108.
## # … with 3,777 more rows, and 1 more variable: rating_1000 <dbl>
ggplot(anime_tv) +
aes(x = episodes) +
geom_density(alpha=0.3, colour = "mediumseagreen", fill = "mediumseagreen") +
theme_linedraw()
Pour pouvoir capter plus d’informations, il est plus pertinent de séparer les animes en deux groupes : le premier groupes contenant les animes ayant moins de 100 épisodes ‘tv_inf’, et le second contenant ceux de 100 épisodes ou plus ‘tv_sup’.
tv_inf <- subset (anime_tv, episodes < 100)
tv_sup <- subset (anime_tv, episodes >= 100)
ggplot(tv_inf) +
aes(x = episodes) +
geom_density(alpha=0.3, colour = "mediumseagreen", fill = "mediumseagreen") +
theme_linedraw()
ggplot(tv_sup) +
aes(x = episodes) +
geom_density(alpha = 0.3, colour = "mediumseagreen", fill = "mediumseagreen") +
theme_linedraw()
Combien d’animes n’ont pas le genre ‘Shounen’ ?
length(which(animes["genre"] == 'Shounen'))
## [1] 9
Lorsque nous lançons ce code, nous n’obtenons que 9 animes de genre ‘Shounen’, cela est du au fait que R prend chaque valeur de la colonne comme étant un seul genre, même lorsque plusieurs genres sont listés.
nb_shounen <- sum(str_detect(animes$genre,'Shounen'), na.rm = TRUE)
nb_shounen
## [1] 1776
non_shounen = nrow(animes) - nb_shounen
non_shounen
## [1] 10518
Parmi les 12294 animes, 10518 ne possèdent pas le genre ‘Shounen’.
Donner la proportion de ‘Shounen’ au sein de chaque type d’anime.
genre_split <- data.frame(do.call("rbind", strsplit(as.character(animes$genre), ", ", fixed = FALSE)))
Ce code permet de faire ressortir le caractère héréditaire des valeurs de R, qui entre alors en compte. Nous savons donc qu’il y a 13 genres au maximum pour un anime, et lorsqu’il y en a moins, chaque genre sera répété jusqu’à 13 fois. Il faut donc séparer chaque genre, et faire en sorte que les genres ne soient pas répétés.
Finalement, nous ne gardons que le premier genre de chaque anime, dans une variable nommée “main_genre”.
animes <- separate(animes, genre, into = "main_genre", sep = ", ")
Le nombre d’occurence est comptée pour chaque genre d’anime par type avec la fonction tabyl. Les résultats sont stockés dans le dataframe genre_df.
Pour trouver le nombre de genre ‘Shounen’ par type :
genre_df %>%
filter(main_genre == "Shounen")
## main_genre Movie Music ONA Other OVA Special TV
## 1 Shounen 11 0 3 0 9 9 17
/! Remarque :
Avec uniquement le genre principal, nous ne trouvons que 49 animes de genre ‘Shounen’ (au lieu de 1776 précédemment). Ce problème sera relevé dans la question 11.
sum(str_detect(animes$main_genre, 'Shounen'), na.rm = TRUE)
## [1] 49
Créer une fonction permettant de donner la proportion d’un genre quelconque au sein de chaque type d’anime.
func_gcount <- function(x){
genre_df %>%
filter(main_genre == x)
}
func_gcount("Shoujo")
## main_genre Movie Music ONA Other OVA Special TV
## 1 Shoujo 0 0 1 0 3 6 3
Il suffit d’écrire func_gcount(x), x étant le nom d’un genre, à écrire avec des guillemets.
Proposer une représentation graphique permettant d’observer au sein de chaque type d’anime, quels genres sont les plus représentés.
top_genre <- animes %>%
group_by(main_genre) %>%
summarise(count = n()) %>%
top_n(n = 10, wt = count)
top_genres <- c("Comedy", "Action", "Adventure", "Drama", "Hentai", "Fantasy", "Music", "Kids", "Dementia", "Historical")
animes %>%
filter((main_genre %in% top_genres) & !is.na(main_genre)) %>%
filter(!is.na(type)) %>%
ggplot() +
geom_point(aes(x = type, y = main_genre, fill = main_genre, color = main_genre),
size = 1, alpha = 0.5) +
labs(
x = "Type",
y = "Genre",
title = "Representation of genre by type"
) +
facet_grid(~type, scales="free_x") +
theme(plot.title = element_text(hjust = 0.5)) +
theme_linedraw()
Avec ce type de représentation, nous n’avons pas le nombre (ou count). Nous pouvons donc faire plus précis…
animes %>%
filter((main_genre %in% top_genres) & !is.na(main_genre)) %>%
filter(!is.na(type)) %>%
ggplot() +
geom_jitter(aes(x = type, y = main_genre, fill = main_genre, color = main_genre), alpha = 0.5) +
labs(
x = "Type",
y = "Genre",
title = "Representation of genre by type"
) +
facet_grid(~type, scales = "free_x") +
theme(plot.title = element_text(hjust = 0.5)) +
theme_linedraw()
…Ou utiliser un autre type de représentation, qui sera plus parlante : l’histogramme.
animes %>%
filter((main_genre %in% top_genres) & !is.na(main_genre)) %>%
filter(!is.na(type)) %>%
ggplot() +
geom_bar(aes(x = type, fill = main_genre), position = "dodge") +
labs(
x = "Type",
y = "Genre",
title = "Representation of genre by type"
) +
facet_grid(~type, scales="free_x") +
theme(plot.title = element_text(hjust = 0.5)) +
theme_linedraw() +
theme(legend.position="bottom")
Ici, nous avons volontairement choisi de séparer le comptage pour chaque genre (position = “dodge”) : ainsi, le nombre count ressort séparément pour chaque genre. Sans cette option, les genres seraient positionnés les uns au dessus des autres.
Pour toutes les variables de types « rating ». Calculer la moyenne, la médiane, l’écart type, la mad (median absolute deviation), le coefficient de variation, la valeur maximum et la valeur minimum. Représentez graphiquement ces résultats.
Il s’agit des variables : ‘rating’, ‘rating_10’, ‘rating_1000’, ’‘rating_1000’’.
Calculs de la moyenne, la médiane, la valeur maximum et la valeur minimum.
#Création d'un vecteur contenant les variable pour pouvoir filtrer le dataframe
ratings <- c('rating', 'rating_10', 'rating_100', 'rating_1000')
#Summary appliqué sur les variables d'animes contenues dans le vecteur ratings
stat_animes <- do.call(cbind, lapply(animes %>% select_if(colnames(animes) %in% ratings), summary))
stats_animes <- as.data.frame(stat_animes)
Il nous manque trois des statistiques demandées [l’écart type, la median absolute deviation, le coefficient de variation] : celles-ci ne sont pas dans la fonction summary().
Nous les calculons donc à l’aide de fonctions:
# Fonction pour la median absolute deviation :
mad_stat <- function(x){
animes %>%
select_if(colnames(animes) %in% ratings)
mad <- mad(x, center = 1, constant = 1.4826, na.rm = TRUE, low = FALSE, high = FALSE)
return(mad)
}
rating <- mad_stat(animes$rating)
rating_10 <- mad_stat(animes$rating_10)
rating_100 <- mad_stat(animes$rating_100)
rating_1000 <- mad_stat(animes$rating_1000)
#R ésultats regroupés dans un dataframe
mad <- cbind(rating,rating_10, rating_100, rating_1000)
# Fonction pour l'écart-type :
sd_stat <- function(x){
animes %>%
select_if(colnames(animes) %in% ratings)
sd <- sd(x,na.rm=TRUE)
return(sd)
}
rating <- sd_stat(animes$rating)
rating_10 <- sd_stat(animes$rating_10)
rating_100 <- sd_stat(animes$rating_100)
rating_1000 <- sd_stat(animes$rating_1000)
sd <- cbind(rating,rating_10, rating_100, rating_1000)
# Fonction pour le coefficient de variation :
cv_stat <- function(x){
animes %>%
select_if(colnames(animes) %in% ratings)
cv <- (sd(x,na.rm=TRUE)/mean(x,na.rm=TRUE))*100
return(cv)
}
rating <- cv_stat(animes$rating)
rating_10 <- cv_stat(animes$rating_10)
rating_100 <- cv_stat(animes$rating_100)
rating_1000 <- cv_stat(animes$rating_1000)
cv <- cbind(rating,rating_10, rating_100, rating_1000)
# Concaténation des statistiques supplémentaires avec celles récupérées du summary().
stats_animes <- rbind(stats_animes, mad, sd, cv)
# Les lignes ainsi ajoutées sont renommées comme suit :
rownames(stats_animes) <- c("Min.", "1st Qu.", "Median", "Mean", "3rd Qu.", "Max.", "NA's", "Mad", "Sd", "Cv")
stats_animes
## rating rating_10 rating_100 rating_1000
## Min. 1.670000 1.670000 22.26028 167.00000
## 1st Qu. 5.880000 5.880000 82.08920 588.00000
## Median 6.570000 6.570000 91.85196 657.00000
## Mean 6.473902 6.473902 90.62368 647.39017
## 3rd Qu. 7.180000 7.180000 100.65867 718.00000
## Max. 10.000000 10.000000 142.28624 1000.00000
## NA's 230.000000 230.000000 230.00000 230.00000
## Mad 8.258082 8.258082 134.69711 972.58560
## Sd 1.026746 1.026746 14.63098 102.67463
## Cv 15.859776 15.859776 16.14476 15.85978
Représentation graphiques des résultats.
Rating <- animes %>%
filter(!is.na(main_genre)) %>%
ggplot() +
aes(x = "", y = rating) +
geom_boxplot(shape = "circle", fill = "mediumseagreen") +
labs(
x = "Rating",
y = "Distribution",
title = "Distribution de ‘rating’ "
) +
theme_linedraw() +
theme(plot.title = element_text(hjust = 0.5))
Rating_10 <- animes %>%
filter(!is.na(main_genre)) %>%
ggplot() +
aes(x = "", y = rating_10) +
geom_boxplot(shape = "circle", fill = "mediumseagreen") +
labs(
x = "Rating_10",
y = "Distribution",
title = "Distribution de ‘rating_10’ "
) +
theme_linedraw() +
theme(plot.title = element_text(hjust = 0.5))
Rating_100 <- animes %>%
filter(!is.na(main_genre)) %>%
ggplot() +
aes(x = "", y = rating_100) +
geom_boxplot(shape = "circle", fill = "mediumseagreen") +
labs(
x = "Rating_100",
y = "Distribution",
title = "Distribution de ‘rating_100’ "
) +
theme_linedraw() +
theme(plot.title = element_text(hjust = 0.5))
Rating_1000 <- animes %>%
filter(!is.na(main_genre)) %>%
ggplot() +
aes(x = "", y = rating_1000) +
geom_boxplot(shape = "circle", fill = "mediumseagreen") +
labs(
x = "Rating_1000",
y = "Distribution",
title = "Distribution de ‘rating_1000’ "
) +
theme_linedraw() +
theme(plot.title = element_text(hjust = 0.5))
plot_grid(Rating, Rating_10, Rating_100, Rating_1000, labels = '', ncol = 4)
Proposer une représentation graphique permettant d’observer s’il existe une différence de notation en fonction du genre d’anime.
Comme précédemment, nous continuerons ici à n’utiliser que les genres principaux.
Genre_rating <- animes %>%
filter((main_genre %in% top_genres) & !is.na(main_genre)) %>%
ggplot() +
aes(x = main_genre, y = rating, fill = main_genre) +
geom_boxplot(shape = "circle") +
scale_fill_hue(direction = 1) +
# coord_flip() +
theme_minimal() +
ylim(0, 10) +
theme(legend.position = "none", axis.text.x = element_text(angle = 90))
Genre_rating10 <- animes %>%
filter((main_genre %in% top_genres) & !is.na(main_genre)) %>%
ggplot() +
aes(x = main_genre, y = rating_10, fill = main_genre) +
geom_boxplot(shape = "circle") +
scale_fill_hue(direction = 1) +
# coord_flip() +
theme_minimal() +
ylim(0, 10) +
theme(legend.position = "none", axis.text.x = element_text(angle = 90))
Genre_rating100 <- animes %>%
filter((main_genre %in% top_genres) & !is.na(main_genre)) %>%
ggplot() +
aes(x = main_genre, y = rating_100, fill = main_genre) +
geom_boxplot(shape = "circle") +
scale_fill_hue(direction = 1) +
# coord_flip() +
theme_minimal() +
ylim(0, 100) +
theme(legend.position = "none", axis.text.x = element_text(angle = 90))
Genre_rating1000 <- animes %>%
filter((main_genre %in% top_genres) & !is.na(main_genre)) %>%
ggplot() +
aes(x = main_genre, y = rating_1000, fill = main_genre) +
geom_boxplot(shape = "circle") +
scale_fill_hue(direction = 1) +
theme_minimal() +
ylim(0, 1000) +
theme(legend.position = "none", axis.text.x = element_text(angle = 90))
plot_grid(Genre_rating, Genre_rating10, Genre_rating100, Genre_rating1000, labels = "AUTO", ncol = 4)
Avec ce type de représentation, nous pouvons visuellement comparer les notes moyennes, minimum et maximum obtenues pour chaque genre, par type.
Pour chaque genre d’anime, représenter graphiquement le top 10 des animes les mieux notés.
Nous cherchons le top 10 des animes par genre parmi les 10 genres les plus représentés dans notre échantillon.
top_anime <- animes %>%
arrange(desc(rating)) %>%
group_by(main_genre) %>% slice(1:10)
top_anime
## # A tibble: 338 × 10
## # Groups: main_genre [41]
## anime_id name main_genre type episodes rating members rating_10 rating_100
## <dbl> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 5114 Fullm… Action TV 64 9.26 793665 9.26 133.
## 2 28977 Ginta… Action TV 51 9.25 114262 9.25 131.
## 3 9969 Ginta… Action TV 51 9.16 151266 9.16 128.
## 4 11061 Hunte… Action TV 148 9.13 425855 9.13 131.
## 5 15417 Ginta… Action TV 13 9.11 81109 9.11 128.
## 6 15335 Ginta… Action Movie 1 9.1 72534 9.1 122.
## 7 918 Ginta… Action TV 201 9.04 336376 9.04 129.
## 8 2904 Code … Action TV 25 8.98 572888 8.98 123.
## 9 1575 Code … Action TV 25 8.83 715151 8.83 120.
## 10 44 Rurou… Action OVA 4 8.83 129307 8.83 124.
## # … with 328 more rows, and 1 more variable: rating_1000 <dbl>
Nous pouvons ensuite effectuer un graphique représentant les top 10 de chaque genre.
top_anime %>%
filter((main_genre %in% top_genres) & !is.na(main_genre)) %>%
ggplot() +
aes(x = main_genre, y = rating) +
geom_point(alpha = 0.7,shape = "circle", colour = "mediumseagreen") +
scale_fill_hue(direction = 1) +
theme_minimal() +
ylim(6.87, 10) +
theme(legend.position="none",axis.text.x = element_text(angle = 90)) +
facet_grid(~main_genre, scales = "free_x")
Pour avoir le détails de chaque animes avec leur nom, nous avons créé une fonction. Pour l’utiliser, il suffit d’entrer comme argument x le nom du genre souhaité entre guillemets.
func_top_anime <- function(x){
top_anime %>%
filter((main_genre %in% c(x)) & !is.na(main_genre)) %>%
ggplot() +
geom_col(aes(x = name, y = rating, fill = name), position = "dodge") +
theme(plot.title = element_text(hjust = 0.5)) +
theme_linedraw() +
theme(legend.position = "right") +
facet_grid(~main_genre, scales = "free_x") +
theme(axis.text.x = element_blank(),
axis.ticks.x = element_blank())
}
func_top_anime("Kids")
Etablir une critique sur les données et les statistiques que vous avez produites. Proposer éventuellement d’autres analyses pour compléter.
Nous remarquons qu’à un caractère spécial près ou à une date près indiquée entre parenthèses, il existe des doublons. Cependant, par manque d’information dans les bases de données fournies, il nous est impossible de traiter ces doublons. Nous supposons que certains constituent des remakes d’animes préexistant mais ne pouvons le confirmer en l’absence d’une variable date. Si une telle variable nous était fournie nous aurions pu traiteer les doublons de la colonne ‘Name’.
Notre second problème est la présence de plusieurs genres séparés par des virgules dans la colonne ‘genre’. Nous avons effectuées les questions en choissisant de ne sélectionner que le premier genre, pensant que celui-ci était le genre principal de l’anime. Cependant, après nous être rendu compte que les genres étaient uniquement classés par ordre alphabétique, nous décidons de proposer un traitement différent de cette variable.
Nous nous proposons de créer des variables dummy pour chaque genre, afin de pouvoir prendre en compte tous les genres pour chaque anime en remplaçant les valeurs manquantes ‘NA’ par 0.
animes_bonus <- rbind(anime_num, anime_unknown)
Dum <- function(x){
flg <- ifelse(str_detect(animes_bonus$genre, as.character(x)), 1, 0)
flg <- replace_na(flg, 0)
return(flg)
}
animes_bonus$Drama <- Dum("Drama")
animes_bonus$Action <- Dum("Action")
animes_bonus$Adventure <- Dum("Adventure")
animes_bonus$Fantasy <- Dum("Fantasy")
animes_bonus$Comedy <- Dum("comedy")
animes_bonus$Sci_Fi <- Dum("Sci-Fi")
animes_bonus$Military <- Dum("Military")
animes_bonus$Romance <- Dum("Romance")
animes_bonus$Mystery <- Dum("Mystery")
animes_bonus$Dementia <- Dum("Dementia")
animes_bonus$Music <- Dum("Music")
animes_bonus$Mecha <- Dum("Mecha")
animes_bonus$School <- Dum("School")
animes_bonus$Game <- Dum("Game")
animes_bonus$Historical <- Dum("Historical")
animes_bonus$Cars <- Dum("Cars")
animes_bonus$Shounen <- Dum("Shounen")
animes_bonus$Harem <- Dum("Harem")
animes_bonus$Horror <- Dum("Horror")
animes_bonus$Martial_Arts <- Dum("Martial Arts")
animes_bonus$Ecchi <- Dum("Ecchi")
animes_bonus$Kids <- Dum("Kids")
animes_bonus$Slice_of_Life <- Dum("Slice of Life")
animes_bonus$Demons <- Dum("Demons")
animes_bonus$Magic <- Dum("Magic")
animes_bonus$Sports <- Dum("Sports")
animes_bonus$Shoujo <- Dum("Shoujo")
animes_bonus$Psychological <- Dum("Psychological")
animes_bonus$Police <- Dum("Police")
animes_bonus$Thriller <- Dum("Thriller")
animes_bonus$Parody <- Dum("Parody")
animes_bonus$Supernatural <- Dum("Supernatural")
animes_bonus$Seinen <- Dum("Seinen")
animes_bonus$Samurai <- Dum("Samurai")
animes_bonus$Super_Power <- Dum("Super Power")
animes_bonus$Vampire <- Dum("Vampire")
animes_bonus$Josei <- Dum("Josei")
animes_bonus$Hentai <- Dum("Hentai")
animes_bonus$Yaoi <- Dum("Yaoi")
animes_bonus$Space <- Dum("Space")
animes_bonus$Shoujo_Ai <- Dum("Shoujo Ai")
animes_bonus$Shounen_Ai <- Dum("Shounen Ai")
animes_bonus$Yuri <- Dum("Yuri")
summary(animes_bonus)
## anime_id name genre type
## Min. : 1 Length:12294 Length:12294 Length:12294
## 1st Qu.: 3484 Class :character Class :character Class :character
## Median :10260 Mode :character Mode :character Mode :character
## Mean :14058
## 3rd Qu.:24794
## Max. :34527
##
## episodes rating members rating_10
## Min. : 1.00 Min. : 1.670 Min. : 5 Min. : 1.670
## 1st Qu.: 1.00 1st Qu.: 5.880 1st Qu.: 225 1st Qu.: 5.880
## Median : 2.00 Median : 6.570 Median : 1550 Median : 6.570
## Mean : 12.38 Mean : 6.474 Mean : 18071 Mean : 6.474
## 3rd Qu.: 12.00 3rd Qu.: 7.180 3rd Qu.: 9437 3rd Qu.: 7.180
## Max. :1818.00 Max. :10.000 Max. :1013917 Max. :10.000
## NA's :340 NA's :230 NA's :230
## rating_100 rating_1000 Drama Action
## Min. : 22.26 Min. : 167.0 Min. :0.000 Min. :0.0000
## 1st Qu.: 82.09 1st Qu.: 588.0 1st Qu.:0.000 1st Qu.:0.0000
## Median : 91.85 Median : 657.0 Median :0.000 Median :0.0000
## Mean : 90.62 Mean : 647.4 Mean :0.164 Mean :0.2314
## 3rd Qu.:100.66 3rd Qu.: 718.0 3rd Qu.:0.000 3rd Qu.:0.0000
## Max. :142.29 Max. :1000.0 Max. :1.000 Max. :1.0000
## NA's :230 NA's :230
## Adventure Fantasy Comedy Sci_Fi
## Min. :0.000 Min. :0.0000 Min. :0 Min. :0.0000
## 1st Qu.:0.000 1st Qu.:0.0000 1st Qu.:0 1st Qu.:0.0000
## Median :0.000 Median :0.0000 Median :0 Median :0.0000
## Mean :0.191 Mean :0.1878 Mean :0 Mean :0.1684
## 3rd Qu.:0.000 3rd Qu.:0.0000 3rd Qu.:0 3rd Qu.:0.0000
## Max. :1.000 Max. :1.0000 Max. :0 Max. :1.0000
##
## Military Romance Mystery Dementia
## Min. :0.00000 Min. :0.0000 Min. :0.00000 Min. :0.00000
## 1st Qu.:0.00000 1st Qu.:0.0000 1st Qu.:0.00000 1st Qu.:0.00000
## Median :0.00000 Median :0.0000 Median :0.00000 Median :0.00000
## Mean :0.03465 Mean :0.1191 Mean :0.04026 Mean :0.01952
## 3rd Qu.:0.00000 3rd Qu.:0.0000 3rd Qu.:0.00000 3rd Qu.:0.00000
## Max. :1.00000 Max. :1.0000 Max. :1.00000 Max. :1.00000
##
## Music Mecha School Game
## Min. :0.00000 Min. :0.00000 Min. :0.00000 Min. :0.00000
## 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000
## Median :0.00000 Median :0.00000 Median :0.00000 Median :0.00000
## Mean :0.06995 Mean :0.07679 Mean :0.09924 Mean :0.01472
## 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000
## Max. :1.00000 Max. :1.00000 Max. :1.00000 Max. :1.00000
##
## Historical Cars Shounen Harem
## Min. :0.00000 Min. :0.000000 Min. :0.0000 Min. :0.00000
## 1st Qu.:0.00000 1st Qu.:0.000000 1st Qu.:0.0000 1st Qu.:0.00000
## Median :0.00000 Median :0.000000 Median :0.0000 Median :0.00000
## Mean :0.06556 Mean :0.005856 Mean :0.1445 Mean :0.02578
## 3rd Qu.:0.00000 3rd Qu.:0.000000 3rd Qu.:0.0000 3rd Qu.:0.00000
## Max. :1.00000 Max. :1.000000 Max. :1.0000 Max. :1.00000
##
## Horror Martial_Arts Ecchi Kids
## Min. :0.00000 Min. :0.00000 Min. :0.00000 Min. :0.0000
## 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.0000
## Median :0.00000 Median :0.00000 Median :0.00000 Median :0.0000
## Mean :0.03001 Mean :0.02156 Mean :0.05181 Mean :0.1309
## 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.0000
## Max. :1.00000 Max. :1.00000 Max. :1.00000 Max. :1.0000
##
## Slice_of_Life Demons Magic Sports
## Min. :0.00000 Min. :0.00000 Min. :0.00000 Min. :0.00000
## 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000
## Median :0.00000 Median :0.00000 Median :0.00000 Median :0.00000
## Mean :0.09924 Mean :0.02391 Mean :0.06328 Mean :0.04417
## 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000
## Max. :1.00000 Max. :1.00000 Max. :1.00000 Max. :1.00000
##
## Shoujo Psychological Police Thriller
## Min. :0.00000 Min. :0.00000 Min. :0.00000 Min. :0.000000
## 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.000000
## Median :0.00000 Median :0.00000 Median :0.00000 Median :0.000000
## Mean :0.05303 Mean :0.01863 Mean :0.01602 Mean :0.007077
## 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.000000
## Max. :1.00000 Max. :1.00000 Max. :1.00000 Max. :1.000000
##
## Parody Supernatural Seinen Samurai
## Min. :0.00000 Min. :0.00000 Min. :0.00000 Min. :0.00000
## 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000
## Median :0.00000 Median :0.00000 Median :0.00000 Median :0.00000
## Mean :0.03319 Mean :0.08435 Mean :0.04449 Mean :0.01204
## 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000
## Max. :1.00000 Max. :1.00000 Max. :1.00000 Max. :1.00000
##
## Super_Power Vampire Josei Hentai
## Min. :0.00000 Min. :0.000000 Min. :0.000000 Min. :0.00000
## 1st Qu.:0.00000 1st Qu.:0.000000 1st Qu.:0.000000 1st Qu.:0.00000
## Median :0.00000 Median :0.000000 Median :0.000000 Median :0.00000
## Mean :0.03782 Mean :0.008297 Mean :0.004392 Mean :0.09281
## 3rd Qu.:0.00000 3rd Qu.:0.000000 3rd Qu.:0.000000 3rd Qu.:0.00000
## Max. :1.00000 Max. :1.000000 Max. :1.000000 Max. :1.00000
##
## Yaoi Space Shoujo_Ai Shounen_Ai
## Min. :0.000000 Min. :0.00000 Min. :0.000000 Min. :0.000000
## 1st Qu.:0.000000 1st Qu.:0.00000 1st Qu.:0.000000 1st Qu.:0.000000
## Median :0.000000 Median :0.00000 Median :0.000000 Median :0.000000
## Mean :0.003172 Mean :0.03099 Mean :0.004474 Mean :0.005287
## 3rd Qu.:0.000000 3rd Qu.:0.00000 3rd Qu.:0.000000 3rd Qu.:0.000000
## Max. :1.000000 Max. :1.00000 Max. :1.000000 Max. :1.000000
##
## Yuri
## Min. :0.000000
## 1st Qu.:0.000000
## Median :0.000000
## Mean :0.003416
## 3rd Qu.:0.000000
## Max. :1.000000
##
Les réponses aux questions 4 à 6 et 10 sont donc retravaillées sur la dataframe ‘animes_bonus’ ainsi obtenu :
not_shounen <- length(animes_bonus$name) - sum(animes_bonus$Shounen)
not_shounen
## [1] 10518
On retrouve bien 10518 animes ne possédant pas le genre ‘Shounen’.
Pour trouver le nombre de genre ‘Shounen’ par type :
shounen_df[2,]
## Shounen Movie Music ONA OVA Special TV NA_
## 2 1 380 0 22 371 263 736 4
Fonction qui compte le nombre d’animes par type.
dumcount <- function(x){
animes_bonus %>%
group_by(type) %>%
count(colname=x)
}
dumcount("Drama")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Drama 2348
## 2 Music Drama 488
## 3 ONA Drama 659
## 4 OVA Drama 3311
## 5 Special Drama 1676
## 6 TV Drama 3787
## 7 <NA> Drama 25
dumcount("Action")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Action 2348
## 2 Music Action 488
## 3 ONA Action 659
## 4 OVA Action 3311
## 5 Special Action 1676
## 6 TV Action 3787
## 7 <NA> Action 25
dumcount("Adventure")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Adventure 2348
## 2 Music Adventure 488
## 3 ONA Adventure 659
## 4 OVA Adventure 3311
## 5 Special Adventure 1676
## 6 TV Adventure 3787
## 7 <NA> Adventure 25
dumcount("Fantasy")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Fantasy 2348
## 2 Music Fantasy 488
## 3 ONA Fantasy 659
## 4 OVA Fantasy 3311
## 5 Special Fantasy 1676
## 6 TV Fantasy 3787
## 7 <NA> Fantasy 25
dumcount("comedy")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie comedy 2348
## 2 Music comedy 488
## 3 ONA comedy 659
## 4 OVA comedy 3311
## 5 Special comedy 1676
## 6 TV comedy 3787
## 7 <NA> comedy 25
dumcount("Sci-Fi")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Sci-Fi 2348
## 2 Music Sci-Fi 488
## 3 ONA Sci-Fi 659
## 4 OVA Sci-Fi 3311
## 5 Special Sci-Fi 1676
## 6 TV Sci-Fi 3787
## 7 <NA> Sci-Fi 25
dumcount("Military")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Military 2348
## 2 Music Military 488
## 3 ONA Military 659
## 4 OVA Military 3311
## 5 Special Military 1676
## 6 TV Military 3787
## 7 <NA> Military 25
dumcount("Romance")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Romance 2348
## 2 Music Romance 488
## 3 ONA Romance 659
## 4 OVA Romance 3311
## 5 Special Romance 1676
## 6 TV Romance 3787
## 7 <NA> Romance 25
dumcount("Mystery")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Mystery 2348
## 2 Music Mystery 488
## 3 ONA Mystery 659
## 4 OVA Mystery 3311
## 5 Special Mystery 1676
## 6 TV Mystery 3787
## 7 <NA> Mystery 25
dumcount("Dementia")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Dementia 2348
## 2 Music Dementia 488
## 3 ONA Dementia 659
## 4 OVA Dementia 3311
## 5 Special Dementia 1676
## 6 TV Dementia 3787
## 7 <NA> Dementia 25
dumcount("Music")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Music 2348
## 2 Music Music 488
## 3 ONA Music 659
## 4 OVA Music 3311
## 5 Special Music 1676
## 6 TV Music 3787
## 7 <NA> Music 25
dumcount("Mecha")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Mecha 2348
## 2 Music Mecha 488
## 3 ONA Mecha 659
## 4 OVA Mecha 3311
## 5 Special Mecha 1676
## 6 TV Mecha 3787
## 7 <NA> Mecha 25
dumcount("School")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie School 2348
## 2 Music School 488
## 3 ONA School 659
## 4 OVA School 3311
## 5 Special School 1676
## 6 TV School 3787
## 7 <NA> School 25
dumcount("Game")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Game 2348
## 2 Music Game 488
## 3 ONA Game 659
## 4 OVA Game 3311
## 5 Special Game 1676
## 6 TV Game 3787
## 7 <NA> Game 25
dumcount("Historical")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Historical 2348
## 2 Music Historical 488
## 3 ONA Historical 659
## 4 OVA Historical 3311
## 5 Special Historical 1676
## 6 TV Historical 3787
## 7 <NA> Historical 25
dumcount("Cars")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Cars 2348
## 2 Music Cars 488
## 3 ONA Cars 659
## 4 OVA Cars 3311
## 5 Special Cars 1676
## 6 TV Cars 3787
## 7 <NA> Cars 25
dumcount("Shounen")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Shounen 2348
## 2 Music Shounen 488
## 3 ONA Shounen 659
## 4 OVA Shounen 3311
## 5 Special Shounen 1676
## 6 TV Shounen 3787
## 7 <NA> Shounen 25
dumcount("Harem")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Harem 2348
## 2 Music Harem 488
## 3 ONA Harem 659
## 4 OVA Harem 3311
## 5 Special Harem 1676
## 6 TV Harem 3787
## 7 <NA> Harem 25
dumcount("Horror")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Horror 2348
## 2 Music Horror 488
## 3 ONA Horror 659
## 4 OVA Horror 3311
## 5 Special Horror 1676
## 6 TV Horror 3787
## 7 <NA> Horror 25
dumcount("Martial Arts")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Martial Arts 2348
## 2 Music Martial Arts 488
## 3 ONA Martial Arts 659
## 4 OVA Martial Arts 3311
## 5 Special Martial Arts 1676
## 6 TV Martial Arts 3787
## 7 <NA> Martial Arts 25
dumcount("Ecchi")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Ecchi 2348
## 2 Music Ecchi 488
## 3 ONA Ecchi 659
## 4 OVA Ecchi 3311
## 5 Special Ecchi 1676
## 6 TV Ecchi 3787
## 7 <NA> Ecchi 25
dumcount("Kids")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Kids 2348
## 2 Music Kids 488
## 3 ONA Kids 659
## 4 OVA Kids 3311
## 5 Special Kids 1676
## 6 TV Kids 3787
## 7 <NA> Kids 25
dumcount("Slice of Life")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Slice of Life 2348
## 2 Music Slice of Life 488
## 3 ONA Slice of Life 659
## 4 OVA Slice of Life 3311
## 5 Special Slice of Life 1676
## 6 TV Slice of Life 3787
## 7 <NA> Slice of Life 25
dumcount("Demons")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Demons 2348
## 2 Music Demons 488
## 3 ONA Demons 659
## 4 OVA Demons 3311
## 5 Special Demons 1676
## 6 TV Demons 3787
## 7 <NA> Demons 25
dumcount("Magic")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Magic 2348
## 2 Music Magic 488
## 3 ONA Magic 659
## 4 OVA Magic 3311
## 5 Special Magic 1676
## 6 TV Magic 3787
## 7 <NA> Magic 25
dumcount("Sports")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Sports 2348
## 2 Music Sports 488
## 3 ONA Sports 659
## 4 OVA Sports 3311
## 5 Special Sports 1676
## 6 TV Sports 3787
## 7 <NA> Sports 25
dumcount("Shoujo")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Shoujo 2348
## 2 Music Shoujo 488
## 3 ONA Shoujo 659
## 4 OVA Shoujo 3311
## 5 Special Shoujo 1676
## 6 TV Shoujo 3787
## 7 <NA> Shoujo 25
dumcount("Psychological")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Psychological 2348
## 2 Music Psychological 488
## 3 ONA Psychological 659
## 4 OVA Psychological 3311
## 5 Special Psychological 1676
## 6 TV Psychological 3787
## 7 <NA> Psychological 25
dumcount("Police")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Police 2348
## 2 Music Police 488
## 3 ONA Police 659
## 4 OVA Police 3311
## 5 Special Police 1676
## 6 TV Police 3787
## 7 <NA> Police 25
dumcount("Thriller")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Thriller 2348
## 2 Music Thriller 488
## 3 ONA Thriller 659
## 4 OVA Thriller 3311
## 5 Special Thriller 1676
## 6 TV Thriller 3787
## 7 <NA> Thriller 25
dumcount("Parody")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Parody 2348
## 2 Music Parody 488
## 3 ONA Parody 659
## 4 OVA Parody 3311
## 5 Special Parody 1676
## 6 TV Parody 3787
## 7 <NA> Parody 25
dumcount("Supernatural")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Supernatural 2348
## 2 Music Supernatural 488
## 3 ONA Supernatural 659
## 4 OVA Supernatural 3311
## 5 Special Supernatural 1676
## 6 TV Supernatural 3787
## 7 <NA> Supernatural 25
dumcount("Seinen")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Seinen 2348
## 2 Music Seinen 488
## 3 ONA Seinen 659
## 4 OVA Seinen 3311
## 5 Special Seinen 1676
## 6 TV Seinen 3787
## 7 <NA> Seinen 25
dumcount("Samurai")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Samurai 2348
## 2 Music Samurai 488
## 3 ONA Samurai 659
## 4 OVA Samurai 3311
## 5 Special Samurai 1676
## 6 TV Samurai 3787
## 7 <NA> Samurai 25
dumcount("Super Power")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Super Power 2348
## 2 Music Super Power 488
## 3 ONA Super Power 659
## 4 OVA Super Power 3311
## 5 Special Super Power 1676
## 6 TV Super Power 3787
## 7 <NA> Super Power 25
dumcount("Vampire")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Vampire 2348
## 2 Music Vampire 488
## 3 ONA Vampire 659
## 4 OVA Vampire 3311
## 5 Special Vampire 1676
## 6 TV Vampire 3787
## 7 <NA> Vampire 25
dumcount("Josei")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Josei 2348
## 2 Music Josei 488
## 3 ONA Josei 659
## 4 OVA Josei 3311
## 5 Special Josei 1676
## 6 TV Josei 3787
## 7 <NA> Josei 25
dumcount("Hentai")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Hentai 2348
## 2 Music Hentai 488
## 3 ONA Hentai 659
## 4 OVA Hentai 3311
## 5 Special Hentai 1676
## 6 TV Hentai 3787
## 7 <NA> Hentai 25
dumcount("Yaoi")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Yaoi 2348
## 2 Music Yaoi 488
## 3 ONA Yaoi 659
## 4 OVA Yaoi 3311
## 5 Special Yaoi 1676
## 6 TV Yaoi 3787
## 7 <NA> Yaoi 25
dumcount("Space")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Space 2348
## 2 Music Space 488
## 3 ONA Space 659
## 4 OVA Space 3311
## 5 Special Space 1676
## 6 TV Space 3787
## 7 <NA> Space 25
dumcount("Shoujo Ai")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Shoujo Ai 2348
## 2 Music Shoujo Ai 488
## 3 ONA Shoujo Ai 659
## 4 OVA Shoujo Ai 3311
## 5 Special Shoujo Ai 1676
## 6 TV Shoujo Ai 3787
## 7 <NA> Shoujo Ai 25
dumcount("Shounen Ai")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Shounen Ai 2348
## 2 Music Shounen Ai 488
## 3 ONA Shounen Ai 659
## 4 OVA Shounen Ai 3311
## 5 Special Shounen Ai 1676
## 6 TV Shounen Ai 3787
## 7 <NA> Shounen Ai 25
dumcount("Yuri")
## # A tibble: 7 × 3
## # Groups: type [7]
## type colname n
## <chr> <chr> <int>
## 1 Movie Yuri 2348
## 2 Music Yuri 488
## 3 ONA Yuri 659
## 4 OVA Yuri 3311
## 5 Special Yuri 1676
## 6 TV Yuri 3787
## 7 <NA> Yuri 25
#On réalise une fonction pour sortir un dataframe donnant le top 10 des notes pour chaque genre.
rating_topten <- function(x){
df10 <- animes_bonus %>%
filter(x == 1) %>%
arrange(desc(rating)) %>%
slice(1:10)
return(df10)
}
top1 <- rating_topten(animes_bonus$Drama)
top2 <- rating_topten(animes_bonus$Action)
top3 <- rating_topten(animes_bonus$Adventure)
top4 <- rating_topten(animes_bonus$Fantasy)
top5 <- rating_topten(animes_bonus$Comedy) #il n'y a pas de top 10
top6 <- rating_topten(animes_bonus$Sci_Fi)
top7 <- rating_topten(animes_bonus$Military)
top8 <- rating_topten(animes_bonus$Romance)
top9 <- rating_topten(animes_bonus$Mystery)
top10 <- rating_topten(animes_bonus$Dementia)
top11 <- rating_topten(animes_bonus$Music)
top12 <- rating_topten(animes_bonus$Mecha)
top13 <- rating_topten(animes_bonus$School)
top14 <- rating_topten(animes_bonus$Game)
top15 <- rating_topten(animes_bonus$Historical)
top16 <- rating_topten(animes_bonus$Cars)
top17 <- rating_topten(animes_bonus$Shounen)
top18 <- rating_topten(animes_bonus$Harem)
top19 <- rating_topten(animes_bonus$Horror)
top20 <- rating_topten(animes_bonus$Martial_Arts)
top21 <- rating_topten(animes_bonus$Ecchi)
top22 <- rating_topten(animes_bonus$Kids)
top23 <- rating_topten(animes_bonus$Slice_of_Life)
top24 <- rating_topten(animes_bonus$Demons)
top25 <- rating_topten(animes_bonus$Magic)
top26 <- rating_topten(animes_bonus$Sports)
top27 <- rating_topten(animes_bonus$Shoujo)
top28 <- rating_topten(animes_bonus$Psychological)
top29 <- rating_topten(animes_bonus$Police)
top30 <- rating_topten(animes_bonus$Thriller)
top31 <- rating_topten(animes_bonus$Parody)
top32 <- rating_topten(animes_bonus$Supernatural)
top33 <- rating_topten(animes_bonus$Seinen)
top34 <- rating_topten(animes_bonus$Samurai)
top35 <- rating_topten(animes_bonus$Super_Power)
top36 <- rating_topten(animes_bonus$Vampire)
top37 <- rating_topten(animes_bonus$Josei)
top38 <- rating_topten(animes_bonus$Hentai)
top39 <- rating_topten(animes_bonus$Yaoi)
top40 <- rating_topten(animes_bonus$Space)
top41 <- rating_topten(animes_bonus$Shoujo_Ai)
top42 <- rating_topten(animes_bonus$Shounen_Ai)
top43 <- rating_topten(animes_bonus$Yuri)
#On regroupe les 43 dataframes obtenu dans un seul nommé animes_topten.
animes_topten <- rbind(top1,top2, top3, top4, top5, top6, top7, top8, top9, top10, top11, top12, top13, top14, top15, top16,
top17, top18, top19, top20, top21, top22, top23, top24, top25, top26, top27, top28, top29, top30,
top31, top32, top33, top34, top35, top36, top37, top38, top39, top40, top41, top42, top43)
#On réalise une fonction qui affiche un barchart des 10 premiers anime selon la notation, par genre.
top_plot <- function(x){
animes_topten %>%
filter(x == 1) %>%
arrange(desc(rating)) %>%
slice(1:10) %>%
ggplot() +
geom_col(aes(x = name, y = rating, fill = name), position = "dodge") +
theme(plot.title = element_text(hjust = 0.5)) +
theme_linedraw() +
theme(legend.position = "right") +
theme(axis.text.x = element_blank(),
axis.ticks.x = element_blank())
}
top_plot(animes_topten$Drama)
top_plot(animes_topten$Action)
top_plot(animes_topten$Adventure)
top_plot(animes_topten$Comedy)
top_plot(animes_topten$Fantasy)
top_plot(animes_topten$Sci_Fi)
top_plot(animes_topten$Military)
top_plot(animes_topten$Romance)
top_plot(animes_topten$Mystery)
top_plot(animes_topten$Dementia)
top_plot(animes_topten$Music)
top_plot(animes_topten$Mecha)
top_plot(animes_topten$School)
top_plot(animes_topten$Game)
top_plot(animes_topten$Historical)
top_plot(animes_topten$Cars)
top_plot(animes_topten$Shounen)
top_plot(animes_topten$Harem)
top_plot(animes_topten$Horror)
top_plot(animes_topten$Martial_Arts)
top_plot(animes_topten$Ecchi)
top_plot(animes_topten$Kids)
top_plot(animes_topten$Slice_of_Life)
top_plot(animes_topten$Demons)
top_plot(animes_topten$Magic)
top_plot(animes_topten$Sports)
top_plot(animes_topten$Shoujo)
top_plot(animes_topten$Psychological)
top_plot(animes_topten$Police)
top_plot(animes_topten$Thriller)
top_plot(animes_topten$Parody)
top_plot(animes_topten$Supernatural)
top_plot(animes_topten$Seinen)
top_plot(animes_topten$Samurai)
top_plot(animes_topten$Super_Power)
top_plot(animes_topten$Vampire)
top_plot(animes_topten$Josei)
top_plot(animes_topten$Hentai)
top_plot(animes_topten$Yaoi)
top_plot(animes_topten$Space)
top_plot(animes_topten$Shoujo_Ai)
top_plot(animes_topten$Shounen_Ai)
top_plot(animes_topten$Yuri)
Proposer une application shiny avec ces données. Vous mettrez en avant l’utilité de votre application (thème et problématique libre). L’application devra être déployée sur shinyapps.io.
Pour répondre à cette deuxième partie, nous avons réalisé une application shiny. Celle ci à pour but d’informer l’utilisateur sur les animes : elle comprend des définitions sur différents termes récurrents et des statistiques descriptives. L’application est assez intuitive, et est destinée à tout individus qui souhaite en apprendre plus sur l’univers de l’animation japonaise. Parallèlement, l’utilisateur aura aussi la possibilité d’enregistrer une liste d’anime à regarder.
Elle est disponible sur le lien : https://showiz.shinyapps.io/Animes_BRISSARD_TSO/